package com.kaishengit.web;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;

import com.kaishengit.pojo.Project;
import com.kaishengit.service.ProjectService;
import com.kaishengit.util.ReportUtil;
import com.opensymphony.xwork2.ActionContext;

public class DataAction extends SimpleBaseAction {

	private static final long serialVersionUID = 1L;
	
	@Resource
	private ProjectService projectService;
	
	private List<Project> projects;
	
	public String execute(){
		
		projects = projectService.findAll();
		
		ActionContext ac = ActionContext.getContext();
		ServletContext sc = (ServletContext) ac.get(ServletActionContext.SERVLET_CONTEXT);
		String filePath = sc.getRealPath("/");
		ReportUtil.reportMain(projects, filePath);
		return MAIN;
	}
	
	//get and set

	public List<Project> getProjects() {
		return projects;
	}

	public void setProjects(List<Project> projects) {
		this.projects = projects;
	}
	
	
	
	
	
	

}
